<!--
 * @Author: your name
 * @Date: 2021-05-12 15:58:13
 * @LastEditTime: 2021-05-14 14:33:18
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vpvmf-web-vue\src\views\ftpManage\pricingManage\pricingTask\pricingCashFlow.vue
-->
<template>
  <div>
    <el-table :data="tableData">
      <el-table-column
        v-for="item in tableProps"
        :key="item.prop"
        :label="item.label"
        :prop="item.prop"
      ></el-table-column>
    </el-table>
    <pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="searchForm.page"
      :page-size="searchForm.size"
      @refresh="searchFunc"
      :total="total"
    ></pagination>
  </div>
</template>

<script>
import { pricingTask } from "@/api/index";
export default {
  props: {
    param: { type: Object, default: () => {} },
    flag: { type: Boolean, default: () => false }
  },
  data() {
    return {
      // 现金流数据
      tableData: [],
      total: 0,
      searchForm: {
        page: 1,
        size: 15,
        acctNo: ""
      },
      tableProps: [
        { prop: "payDate", label: "支付日期" },
        { prop: "amount", label: "本金流" },
        { prop: "curBal", label: "当前余额" },
        { prop: "discountFacator", label: "折现因子" },
        { prop: "interest", label: "利息流" },
        { prop: "interestDay", label: "利息计算天数" },
        { prop: "pv", label: "现值" },
        { prop: "pvt", label: "现金流期限" },
        { prop: "pvtr", label: "现金流期限利率" },
        { prop: "pvxt", label: "当前总现值" },
        { prop: "rate", label: "插值利率" },
        { prop: "term", label: "插值天数" },
        { prop: "totalCashFlow", label: "本息和" }
      ]
    };
  },
  created() {
    this.searchFunc();
  },
  watch: {
    flag() {
      if (this.flag) {
        this.searchForm.page = 1;
        this.searchFunc();
      }
    }
  },
  methods: {
    searchFunc() {
      let data ={
        pk:this.param.acctNo+"$"+this.param.dataDt,
        positionTableFix:this.param.tableName,
        sceneCode:this.param.sceneCode,
        page:this.searchForm.page,
        size:this.searchForm.size
      };
      // data.acctNo = this.param.acctNo;
      pricingTask.pricingCashFlow(data).then(res => {
        if (res.code == 200) {
          this.tableData = res.row;
          this.total = res.total;
        }
      });
    },
    handleSizeChange(val) {
      this.searchForm.size = val;
      this.searchFunc();
    },
    handleCurrentChange(val) {
      this.searchForm.page = val;
      this.searchFunc();
    }
  }
};
</script>

<style lang="scss" scoped>
</style>